<?php

include_once("../../php/include_all.php");
$idkeg = $_GET['id_kegiatan'];
$udesa=get_data("select p.nama_program, k.nama_kegiatan, s.nama_skpd, u.indikator_program, u.indikator_hasil, u.indikator_keluaran, u.target_hasil, u.tahun from mus_usulankecamatan u, mus_program p, mus_kegiatan k, mus_skpd s where s.id_skpd=u.id_skpd and u.id_kegiatan=k.id_keg and p.id_program=k.id_program and id_usulankec=$idkeg");
$rinudeda = get_datas ("select r.lokasi, r.volume, r.apbdkab, r.apbdprov, r.apbn, r.prioritas, r.status from mus_rinc_usulan_kec r, mus_usulankecamatan u where u.id_usulankec=r.id_usulankec and r.id_usulankec=$idkeg order by r.id_rinc_usulan_kec");
$tot = get_data ("select distinct id_kegiatan, R.id_usulankec, 
(select sum(ur.apbdkab) from mus_rinc_usulan_kec ur where R.id_usulankec=ur.id_usulankec)as tot_apbdkab,
(select sum(ur.apbdprov) from mus_rinc_usulan_kec ur where R.id_usulankec=ur.id_usulankec)as tot_apbdprov,
(select sum(ur.apbn) from mus_rinc_usulan_kec ur where R.id_usulankec=ur.id_usulankec)as tot_apbn,
((select sum(ur.apbdprov) from mus_rinc_usulan_kec ur where R.id_usulankec=ur.id_usulankec)+(select sum(ur.apbdkab) from mus_rinc_usulan_kec ur where R.id_usulankec=ur.id_usulankec)+(select sum(ur.apbn) from mus_rinc_usulan_kec ur where R.id_usulankec=ur.id_usulankec)) as tot   
from mus_rinc_usulan_kec R, mus_usulankecamatan U, mus_program P, mus_kegiatan K, mus_skpd S where S.id_skpd=U.id_skpd and U.id_kegiatan=K.id_keg and K.id_program=P.id_program and U.id_usulankec=R.id_usulankec and U.id_usulankec=$idkeg");
		//printf($rinudeda);
echo "
	<table class='table-form'>
		<tr>
			<td>Program</td><td>:</td><td>".$udesa['nama_program']."</td>
		</tr>
		<tr>
			<td>Kegiatan</td><td>:</td><td>".$udesa['nama_kegiatan']."</td>
		</tr>
		<tr>
			<td>SKPD Tujuan</td><td>:</td><td>".$udesa['nama_skpd']."</td>
		</tr>
		<tr>
			<td>Indikator Program</td><td>:</td><td>".$udesa['indikator_program']."</td>
		</tr>
		<tr>
			<td>Indikator Keluaran</td><td>:</td><td>".$udesa['indikator_keluaran']."</td>
		</tr>
		<tr>
			<td>Target</td><td>:</td><td>".$udesa['target_hasil']."</td>
		</tr>
		<tr>
			<td>Tahun</td><td>:</td><td>".$udesa['tahun']."</td>
		</tr>
	</table>
	<br>
	<table class='table table-bordered' align='center'>
		<tr>
			
			<th style='text-align:center'>LOKASI</th>
			<th style='text-align:center'>VOLUME</th>
			<th style='text-align:center'>APBD KAB.</th>
			<th style='text-align:center'>APBD PROV.</th>
			<th style='text-align:center'>APBN</th>
			<th style='text-align:center'>PRIORITAS</th>
			<th style='text-align:center'>STATUS</th>
		</tr>
		";
		//$no=1;
		foreach ($rinudeda as $are){
			echo "<tbody>
			<tr>
				<td>".$are['lokasi']."</td>
				<td style='text-align:center'>".$are['volume']."</td>
				<td style='text-align:right'>".$are['apbdkab']."</td>
				<td style='text-align:right'>".$are['apbdprov']."</td>
				<td style='text-align:right'>".$are['apbn']."</td>
				<td style='text-align:center'>".$are['prioritas']."</td>
				<td style='text-align:center'>".$are['status']."</td>
			</tr>";
			//$no++;
		} echo "
			<tr>
				<td colspan='2'></td>
				<td style='text-align:right'><b>".$tot['tot_apbdkab']."</b></td>
				<td style='text-align:right'><b>".$tot['tot_apbdprov']."</b></td>
				<td style='text-align:right'><b>".$tot['tot_apbn']."</b></td>
				<td colspan='2s'></td>
			</tr></tbody>
	</table>
";
?>